import request from '/src/axios.js';
import {baseUrl} from '/src/config/env.js';

export const userApi = {
  usersFuzzy: () => request({
    url: baseUrl + '/api-user/users/fuzzy',
    method: 'get',
  }),
  userPage: (current, size, params) => request({
    url: baseUrl + '/api-user/users/userPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  }),
  userList: () => request({
    url: baseUrl + '/api-user/users/list',
    method: 'get'
  }),
  remove: (ids) => request({
    url: baseUrl + '/api-user/users/remove/' + ids,
    method: 'post',
    // params: {
    //   ids,
    // }
  }),
  check: (username) => request({
    url: baseUrl + '/api-user//users/name/' + username,
    method: 'get'
  }),
  create: (row) => request({
    url: baseUrl + '/api-user/users/create',
    method: 'post',
    data: row,
    params: {
      tenantId: row.tenantId
    }
  }),
  update: (row) => request({
    url: baseUrl + '/api-user/users/update',
    method: 'post',
    data: row
  }),
  grant: (userId, roleIds) => request({
    url: baseUrl + '/api-user/auth/grantUserRoles',
    method: 'post',
    params: {
      userId,
    },
    data: {
      roleIds
    }
  }),
  getUser: (id) => request({
    url: baseUrl + '/api-user/users/userId/' + id,
    method: 'get'
  }),
  getUserInfo: () => request({
    url: baseUrl + '/api-user/users/current',
    method: 'get',
  }),
  resetPassword: (userId) => request({
    url: '/api-user/users/' + userId + '/password',
    method: 'put'
  }),
  updatePassword: (id, oldPassword, newPassword) => request({
    url: '/api-user/users/password',
    method: 'post',
    params: {
      id,
      oldPassword,
      newPassword
    }
  }),
  exportUser: (oldPassword, newPassword, newPassword1) => request({
    url: baseUrl + "/api-user/users/export",
    method: 'post',
  })
};
